package com.example.rbac.handle;

import com.example.rbac.Exception.ResultErrorException;
import com.example.rbac.entity.defefult.Result;
import com.example.rbac.uitls.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Created by Administrator on 2017/10/15.
 */
@ControllerAdvice
public class ExceptionControllerAdvices {
    public static final  Logger logger = LoggerFactory.getLogger(ExceptionControllerAdvices.class);

    @ExceptionHandler(ResultErrorException.class)
    public Result ResultErrorExceptionError(Integer code, String msg){
        logger.info("===========应用到所有@RequestMapping注解的方法，在其抛出Exception异常时执行");
        logger.info("ResultErrorException:{}", msg);
        return ResultUtil.erorr(code, msg);
    }
}
